package Spackage;

class Triangle extends Shape
{
    private double side1;
    private double side2;
    private double side3;

    // 构造
    public Triangle(double side1, double side2, double side3)
    {
        this.side1 = side1;
        this.side2 = side2;
        this.side3 = side3;
    }

    // 实现 area 方法
    public double area()
    {
        double s = (side1 + side2 + side3) / 2;
        return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
    }

    // 实现 perimeter 方法
    public double perimeter()
    {
        return side1 + side2 + side3;
    }
}
